﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Extensions.Configuration;

namespace BunnyEater.Common.Jwt
{
    /// <summary>
    /// JWT配置类，用于管理JWT相关的配置信息
    /// </summary>
    public class JwtConfig
    {
        /// <summary>
        /// JWT配置信息
        /// </summary>
        public static JwtInfo? JwtInfo { get; private set; }

        /// <summary>
        /// 初始化JWT配置信息
        /// </summary>
        /// <param name="configuration">配置对象</param>
        public static void InitJwtInfo(IConfiguration configuration)
        {
            JwtInfo _jwtInfo = new JwtInfo();
            //_jwtInfo.SecurityKey = configuration["Jwt:SecurityKey"];
            _jwtInfo.Issuer = configuration["Jwt:Issuer"];
            _jwtInfo.Audience = configuration["Jwt:Audience"];
            _jwtInfo.ExpiryMinutes = int.Parse(configuration["Jwt:ExpiryMinutes"]);
            JwtInfo = _jwtInfo;
        }
    }

    /// <summary>
    /// JWT信息配置类
    /// </summary>
    public class JwtInfo
    {
        /// <summary>
        /// 密钥
        /// </summary>
        public string? SecurityKey { get; set; }
        /// <summary>
        /// 颁发者
        /// </summary>
        public string? Issuer { get; set; }
        /// <summary>
        /// 接收者
        /// </summary>
        public string? Audience { get; set; }
        /// <summary>
        /// 过期时间（分钟）
        /// </summary>
        public int ExpiryMinutes { get; set; }
    }
}